package com.czy.basecommon.utils.base;

import androidx.lifecycle.LifecycleOwner;

import com.rxjava.rxlife.BaseScope;

import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;

/**
 *desc:
 *author:mid
 *addtime:2020/5/13 11:22
 * 数据仓库
 */
public  abstract class BaseRepository  {
    private CompositeDisposable mCompositeDisposable;
    public MyBaseDataCallBack mDataCallBack;

    //数据回调接口
    public interface MyBaseDataCallBack<T> {
        void onDataSuccessCallBack( T t);
        void onDataFailCallBack(T t,T t1);
    }

    public BaseRepository() {

    }
    protected void addDisposable(Disposable disposable) {
        if (mCompositeDisposable == null) {
            mCompositeDisposable = new CompositeDisposable();
        }
        mCompositeDisposable.add(disposable);
    }

    public void unDisposable() {
        if (mCompositeDisposable != null && mCompositeDisposable.isDisposed()) {
            mCompositeDisposable.clear();
        }
    }
}
